#include <gtest\gtest.h>
#include <Zaf\String\Trim.h>



TEST(Trim, TrimString) {

	//
	std::string str("");
	const std::string cstr(str);
	Zaf::String::Trim(str);
	ASSERT_EQ("", str);
	ASSERT_EQ("", Zaf::String::Trim(cstr));

	//
	str = "  \t\t\r\n \r\n  ";
	const std::string cstr2(str);
	Zaf::String::Trim(str);
	ASSERT_EQ("", str);
	ASSERT_EQ("", Zaf::String::Trim(cstr2));

	//
	str = "\t\n  aa ffd fd  \n\r\t  ";
	const std::string cstr3(str);
	Zaf::String::Trim(str);
	ASSERT_EQ("aa ffd fd", str);
	ASSERT_EQ("aa ffd fd", Zaf::String::Trim(cstr3));

	//
	str = "123";
	const std::string cstr4(str);
	Zaf::String::Trim(str);
	ASSERT_EQ("123", str);
	ASSERT_EQ("123", Zaf::String::Trim(cstr4));
}



TEST(Trim, TrimWideString) {

	//
	std::wstring str(L"");
	const std::wstring cstr1(str);
	Zaf::String::Trim(str);
	ASSERT_EQ(L"", str);
	ASSERT_EQ(L"", Zaf::String::Trim(cstr1));

	//
	str = L"  \t\t\r\n \r\n  ";
	const std::wstring cstr2(str);
	Zaf::String::Trim(str);
	ASSERT_EQ(L"", str);
	ASSERT_EQ(L"", Zaf::String::Trim(cstr2));

	//
	str = L"\t\n  aa ffd fd  \n\r\t  ";
	const std::wstring cstr3(str);
	Zaf::String::Trim(str);
	ASSERT_EQ(L"aa ffd fd", str);
	ASSERT_EQ(L"aa ffd fd", Zaf::String::Trim(cstr3));

	//
	str = L"123";
	const std::wstring cstr4(str);
	Zaf::String::Trim(str);
	ASSERT_EQ(L"123", str);
	ASSERT_EQ(L"123", Zaf::String::Trim(cstr4));
}



TEST(Trim, TrimOthers) {

	//
	std::string str("00000001111222222333");
	const std::string cstr(str);
	Zaf::String::Trim(str, "023");
	ASSERT_EQ("1111", str);
	ASSERT_EQ("1111", Zaf::String::Trim(cstr, "023"));

	//
	std::wstring wstr(L"12310933aaslvalndg3019");
	const std::wstring cwstr(wstr);
	Zaf::String::Trim(wstr, L"01239");
	ASSERT_EQ(L"aaslvalndg", wstr);
	ASSERT_EQ(L"aaslvalndg", Zaf::String::Trim(cwstr, L"01239"));
}